package cn.daniellee.plugin.ea;

import cn.daniellee.plugin.ea.command.AloneCommand;
import cn.daniellee.plugin.ea.listener.EntityListener;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.List;

public class ExplodeAlone extends JavaPlugin {

	private static ExplodeAlone instance;

	private String prefix;

	private List<String> worlds;

	public void onEnable(){
		instance = this;

		loadConfig();
		getLogger().info(" ");
		getLogger().info(">>>>>>>>>>>>>>>>>>>>>>>> ExplodeAlone Loaded <<<<<<<<<<<<<<<<<<<<<<<<");
		getLogger().info(">>>>> If you encounter any bugs, please contact author's QQ: 768318841 <<<<<");
		getLogger().info(" ");

		Bukkit.getPluginManager().registerEvents(new EntityListener(), this);
		Bukkit.getPluginCommand("explodealone").setExecutor(new AloneCommand());
	}

	public void loadConfig() {
		getLogger().info("Loading config...");
		if(!getDataFolder().exists()) getDataFolder().mkdirs();
		prefix = "&7[&b" + getConfig().getString("prompt-prefix", "&6ExplodeAlone") + "&7] &3: &r";
		worlds = getConfig().getStringList("setting.worlds");
		saveDefaultConfig();
	}

	@Override
	public void onDisable() {
		getLogger().info(" ");
		getLogger().info(">>>>>>>>>>>>>>>>>>>>>>>> ExplodeAlone Unloaded <<<<<<<<<<<<<<<<<<<<<<<<");
		getLogger().info(" ");
	}

	public static ExplodeAlone getInstance() {
		return instance;
	}

	public String getPrefix() {
		return prefix;
	}

	public List<String> getWorlds() {
		return worlds;
	}
}